<!DOCTYPE html>
<html>

	<head lang="en">
		<title>骡窝日报</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
		<script src="/js/plugins/jquery/jquery.min.js"></script>
		<script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/news.css" />
		<script src="/js/plugins/jrender/jrender.min.js"></script>
		<link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
		<script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
		<script src="/js/common.js"></script>
		<link rel="stylesheet" href="/js/plugins/dialog2/dialog.css" />
		<script src="/js/plugins/dialog2/dialog.min.js"></script>
		<script>
            $(function () {
                //首先我们需要获取当前页的标签
                var currentInput = $('#currentPage');
                //因为我们手机滚动之前的数据就没有了,只有当前查出来的不合理
                var arr=[];
                var pages=1;
                function query() {
                    //获取当前页
                    var currentPage = currentInput.val();
                    $.get("/daily/list",{currentPage:currentPage},function (data) {
                        pages=data.pages;
                        //把两个数组的数据合并在一起,就可以滚动了
                        $.merge(arr,data.list);
                        var json={
                            list:arr
                        }
                        $('.carousel-inner').renderValues(json,{
                            getHref:function (item,value) {
                                var href = $(item).data("href");
                                $(item).attr("href",href+value);
                            }
                        });

                    });
                    currentInput.val(parseInt(currentPage)+1);
                }
                query();
                $(window).scroll(function () {
                    if($(document).scrollTop()+$(window).height()>=$(document).height()-10){
                        var val = currentInput.val();
                        if(val<=pages){
                            query();
                        }else{
                            $(document).dialog({
                                type : 'notice',
                                infoText: '已经加载到底了!!!',
                                autoClose: 1000
                            });
                        }
                    }
                });


            });

		</script>
	</head>

	<body>
	<input type="hidden" name="currentPage" id="currentPage" value="1"/>

	<div class="container news">
		<div class="news">

			<h6 class="news-title">骡窝日报 </h6>
			<div class="carousel-inner">

					<div class="row" render-loop="list"><div class="col-6">

						<a data-href="newsContent.html?id=" render-key="list.id" render-fun="getHref">
							<img class="rounded" width="100%" height="110px"  render-src="list.coverUrl">
						</a>

						<div class="caption">
							<p>
								<span render-html="list.dailyCreateTime"> </span>
							</p>
							<a href="newsContent.html">
								<p render-html="list.title"></p>
							</a>
						</div>
					</div></div>
				</div></div>
		</div>
	</div>
</body>
</html>